POV-Ray : Newsgroups : povray.general : Bug in processing #while loop for low comparison values? : Re: Bug in processing #while loop for low comparison values? Server Time
1 Aug 2024 20:14:34 EDT (-0400)
  Re: Bug in processing #while loop for low comparison values?  
From: Warp
Date: 12 Apr 2005 19:04:53
Message: <425c5415@news.povray.org>
hob### [at] gatenet wrote:
>   #declare Loop = Loop + 0.1;

  Not a bug. A limitation of floating point numbers.

  The number 0.1 is pathological in that it cannot be represented
accurately in the base-2 floating point format of the FPU (for the
same reason that for example 1/3 cannot be represented accurately
with a base-10 floating point representation).

  When you add 0.1 like this, the error caused by this accumulates
in such way that after you have added it ten times the result is
not 1 but a tiny fraction less.

  If you use integers only (ie. "#declare Loop = Loop + 1;") then
there's no such problem (because floating point numbers can
represent integers accurately up to a quite big value).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.